from book.models import BookInfo, PeopleInfo
book = BookInfo.objects.get(id=1)
book = BookInfo.objects.get(pk=5)

books = BookInfo.objects.all()

count = PeopleInfo.objects.count()

from book.models import BookInfo, PeopleInfo

BookInfo.objects.filter(id__exact=1)
BookInfo.objects.filter(id=1)
BookInfo.objects.get(id=1)
BookInfo.objects.get(pk=1)

BookInfo.objects.filter(name__contains='湖')

BookInfo.objects.filter(name__endswith='部')

BookInfo.objects.filter(name__isnull=True)

BookInfo.objects.filter(id__in=[1, 3, 5])

BookInfo.objects.filter(id__gt=3)

BookInfo.objects.filter(pub_date__year=1980)

BookInfo.objects.filter(pub_date__gt='1990-1-1')

from django.db.models import F, Q
BookInfo.objects.filter(readcount__gte=F('commentcount'))

BookInfo.objects.filter(readcount__gte=F('commentcount')*2)

BookInfo.objects.filter(readcount__gt=20, id__lt=3)

BookInfo.objects.filter(Q(readcount__gt=20) | Q(id__lt=3))

BookInfo.objects.filter(~Q(id=3))

from django.db.models import Sum, Max
BookInfo.objects.aggregate(Sum('readcount'))
BookInfo.objects.aggregate(Max('readcount'))

BookInfo.objects.all()
BookInfo.objects.all().order_by('-readcount')


book = BookInfo.objects.get(id=1)
book.peopleinfo_set.all()

people = PeopleInfo.objects.get(id=1)
people.book

people = PeopleInfo.objects.get(id=1)
people.book_id

book = BookInfo.objects.filter(peopleinfo__name='郭靖')

book = BookInfo.objects.filter(peopleinfo__description__contains='八')

peoples = PeopleInfo.objects.filter(book__name='天龙八部')

peoples = PeopleInfo.objects.filter(book__readcount__gt=30)